<?php ob_start();session_start();?>
<?php
if (isset($_POST['ThemSanPham']))
{
	
		$MaLoai = $_POST['MaLoai'];	
		$TenSanPham = $_POST['TenSanPham'];	
		$MaThuongHieu = $_POST['MaThuongHieu'];
		$NgayNhap = $_POST['NgayNhap'];	
		$MoTa = $_POST['MoTa'];	
		$DonGia = $_POST['DonGia'];	
		$KhuyenMai = $_POST['MaKhuyenMai'];	
		$TinhTrang = $_POST['TinhTrang'];	
		$name="../Another/Images/SanPham/".$_FILES['HinhAnh']['name'];	
			
		if($TenSanPham)
		{
			include_once "connection.php";
			$sql="Select * from sanpham where TenSanPham='".$TenSanPham."'";
			$KT=mysql_query($sql);
			
			if(mysql_num_rows($KT)!=0)
			{
				echo"Tên sản phẩm ".$TenSanPham." đã tồn tại, nhập tên sản phẩm khác</br>";
			}
			else
			{
				$query="Insert into sanpham( MaLoai, MaThuongHieu, TenSanPham, NgayNhap, MoTa, HinhAnhSP, DonGiaDuKien, TinhTrang, MaKhuyenMai)values('".$MaLoai."', '".$MaThuongHieu."', '".$TenSanPham."','".$NgayNhap."','".$MoTa."','".$name."','".$DonGia."','".$TinhTrang."','".$KhuyenMai."')";
				$result=mysql_query($query);	
			}
			header("location:../MyModel/TrangAdmin_con.php?themsanpham");
			mysql_close($con);
		}	
	}
?>
